import java.io.DataOutputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Random;

public class WriteNumbers {
    public static void main(String[] args) {
        String fileName = "out.dat";
        int numberOfNumbers = 100;
        int lower = 1000;
        int upper = 2000;

        try (DataOutputStream dos = new DataOutputStream(new FileOutputStream(fileName))) {
            Random random = new Random();
            for (int i = 0; i < numberOfNumbers; i++) {
                int randomNumber = random.nextInt((upper - lower) + 1) + lower;
                dos.writeInt(randomNumber);
            }
            System.out.println("Random numbers have been written to " + fileName);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}